// 创建路由
import App from '@/views/App'
// import Fast from '@/views/Fast'
import Home from '@/views/Home'
// import Login from '@/views/Login'
// import Mine from '@/views/Mine'
// import Practice from '@/views/Practice'
// import Projects from '@/views/Projects'
// import Select from '@/views/Select'
import { lazy } from 'react'
import { createBrowserRouter as createRouter } from 'react-router-dom'

// 实现路由的懒加载
// lazy 函数用于实现组件的懒加载
const Fast = lazy(() => import('@/views/Fast'))
const Login = lazy(() => import('@/views/Login'))
const Mine = lazy(() => import('@/views/Mine'))
const Practice = lazy(() => import('@/views/Practice'))
const Projects = lazy(() => import('@/views/Projects'))
const Select = lazy(() => import('@/views/Select'))


const router = createRouter([
    {
        path: 'login',
        element: <Login />
    },
    {
        path: '/',
        element: <App />,
        children: [

            {
                // path: 'home',
                // 标记为 index 的页面，会进入父路由的时候，默认展示该子路由
                index: true,
                element: <Home />
            },
            {
                path: 'fast',
                element: <Fast />
            },
            {
                path: 'mine',
                element: <Mine />
            },
            {
                path: 'select/:id',
                element: <Select />
            },
            {
                path: 'practice',
                element: <Practice />
            },
            {
                path: 'projects',
                element: <Projects />
            },
        ]
    }
])

export default router